package demo1;

public class demo1 {
    public static void main(String[] args) throws InterruptedException {
        Thread t2 = new Thread(()->{
            for (int i = 0; i < 3; i++) {
                System.out.println("t2");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        Thread t1 = new Thread(()->{
            for (int i = 0; i < 5; i++) {
                System.out.println("t1");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        t1.start();
        t2.start();

        t1.join();
        t2.join();

        System.out.println("main end");
    }
}
